function get(url, callback){
    // Ctrl + 刷新 => 强制刷新
    var ajax = new XMLHttpRequest();
    ajax.onreadystatechange = () => {
        if (ajax.readyState == 4 && ajax.status == 200){
            var json = ajax.responseText;
            var result = JSON.parse(json);
            callback(result);
        }
    }
    ajax.open("get",url);
    ajax.send(null);
}

function post(url, data, callback){
    var ajax = new XMLHttpRequest();
    ajax.onreadystatechange = () => {
        if (ajax.readyState == 4 && ajax.status == 200){
            var json = ajax.responseText;
            var result = JSON.parse(json);
            callback(result);
        }
    }
    ajax.open("post", url);
    // 设置提交数据的内容类型
    if (data instanceof String){
        // 表单提交参数
        ajax.setRequestHeader("Content-Type","application/x-www-form-urlencoded");
    } else if (data instanceof FormData){
        // 文件上传
        ajax.setRequestHeader("Content-Type","multipart/form-data");
    }
    // else {
    //     ajax.setRequestHeader("Content-Type", "application/json");
    // }
    ajax.send(data);
}